#include "./MutexLock.h"
#include "./Condition.h"
#include <iostream>
#include <thread>
using namespace std;
using namespace yhaida;
//--------------------------------1.-----------------------------------
MutexLock mutex;
Condition pcond(mutex);
int i = 0;
// void a()
// {
//     MutexLockGuard guard(mutex);
//     while (i == 0)
//     {
//         cout << "wait" << endl;
//         // pcond.wait();
//         cout<<pcond.waitForSeconds(2)<<endl;
//         cout << "signal" << endl;
//     }
//     cout << "mutexID:" << mutex.isLockedByThisThread() << endl;
// }
void b()
{
    MutexLockGuard guard(mutex);
    cout << "mutexID:" << CurrentThread::currend_tid << endl;
}
//--------------------------------2.-----------------------------------
int main()
{
    //--------------------------------1.-----------------------------------
    // cout << "mutexID:" << mutex.isLockedByThisThread() << endl;
    // std::thread t(a);
    // sleep(10);
    // i=1;
    // pcond.notify();
    // t.join();
    //--------------------------------2.-----------------------------------
    cout << "mutexID:" << CurrentThread::currend_tid << endl;
    std::thread t1(b);
    std::thread t2(b);
    t1.join();
    t2.join();
    return 0;
}